import matplotlib.pyplot as plt
import numpy as np

# 生成示例数据（假设三个类别）
np.random.seed(42)
categories = ['A', 'B', 'C']
num_points = 30

# 为每个类别生成数据
data = {
    'A': {'x': np.random.randn(num_points), 'y': np.random.randn(num_points)},
    'B': {'x': np.random.randn(num_points) + 3, 'y': np.random.randn(num_points) + 3},
    'C': {'x': np.random.randn(num_points) - 3, 'y': np.random.randn(num_points) - 3},
}

# 定义每个类别的颜色和标记
colors = {'A': 'red', 'B': 'blue', 'C': 'green'}
markers = {'A': 'o', 'B': 's', 'C': '^'}

# 绘制散点图
plt.figure(figsize=(8, 6))
for category in categories:
    plt.scatter(
        data[category]['x'], 
        data[category]['y'],
        c=colors[category],
        marker=markers[category],
        label=category,
        alpha=0.7,
        edgecolors='w'
    )

# 添加标签和图例
plt.title("Scatter Plot with Three Categories")
plt.xlabel("X Values")
plt.ylabel("Y Values")
plt.legend()
plt.grid(True, linestyle='--', alpha=0.5)
plt.show()